#include <iostream>
#include <cstdlib>

using namespace std;

class DayOfYear
{
private:
    int month;
    int day;
    void testDate();
public:
    DayOfYear(int monthValue, int dayValue);
    DayOfYear(int monthValue);
    DayOfYear();
    void input();
    int getMonth();
    int getDay();
};

int main()
{
    DayOfYear date1(2, 27), date2(11), date3;
    // cout << "Initialized dates: \n";
    cout << date1.getDay() << endl
         << date2.getDay() << endl
         << date3.getMonth() << endl;

    date3.input();

    cout << date3.getDay();
    
    return 0;
}

DayOfYear::DayOfYear(int monthValue, int dayValue)
    : month(monthValue), day(dayValue)
{
    testDate();
}

DayOfYear::DayOfYear(int monthValue)
    : month(monthValue), day(1)
{
    testDate();
}

DayOfYear::DayOfYear()
    : month(1), day(1)
{}

void DayOfYear::testDate()
{
    if ((month < 1) || (month > 12))
    {
        cout << "Illegal month value !\n";
        exit(1);
    }
    if ((day < 1) || (day > 31))
    {
        cout << "Illegal day value !\n";
        exit(1);
    }
}

int DayOfYear::getMonth()
{
    return month;
}

int DayOfYear::getDay()
{
    return day;
}

void DayOfYear::input()
{
    cout << "Enter the month as a number: ";
    cin >> month;
    cout << "Enter the day as the number: ";
    cin >> day;
}